/**********************************************************
 * AuctionsManagerAction.java.java
 * Created by Ashutosh
 * Last modified Date: Sep 18, 2008 10:44:54 AM by Ashutosh
 * Revision: <svn revision #>
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.hibernate.Criteria;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.CriteriaQuery;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.SimpleExpression;
import org.hibernate.engine.TypedValue;

import com.opensymphony.xwork2.ActionContext;
import com.printeverywhere.delegator.CategoryManagerServiceDelegator;
import com.printeverywhere.delegator.CommonFunctionDelegator;
import com.printeverywhere.delegator.ItemsServiceDelegator;
import com.printeverywhere.delegator.SearchServiceDelegator;
import com.printeverywhere.delegator.UserServiceDelegator;
import com.printeverywhere.dto.AuctionInvoices;
import com.printeverywhere.dto.BidStatus;
import com.printeverywhere.dto.GeneralCategories;
import com.printeverywhere.dto.GeneralCategoriesWOS;
import com.printeverywhere.dto.GeneralOptions;
import com.printeverywhere.dto.ItemCategories;
import com.printeverywhere.dto.Items;
import com.printeverywhere.dto.Itemtype;
import com.printeverywhere.dto.Languages;
import com.printeverywhere.dto.ListingOptions;
import com.printeverywhere.dto.LocationCategories;
import com.printeverywhere.dto.LocationCategoriesWOS;
import com.printeverywhere.dto.Transactions;
import com.printeverywhere.dto.User;
import com.printeverywhere.util.AdminConstants;
import com.printeverywhere.util.DateUtil;
import com.printeverywhere.util.HibernateUtil;
import com.printeverywhere.util.SearchCriteria;
import com.printeverywhere.util.SessionUtil;
import com.printeverywhere.util.Sort;

public class AuctionsManagerAction extends AdminEngineManagement implements ServletRequestAware, Criterion{
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(AuctionsManagerAction.class);

	private String searchBy;

	private String language;

	private HttpServletRequest request;

	private String terms;

	private int pageSize = 0;

	private String sort;

	private GeneralOptions generalOptions;

	private ListingOptions listingOptions;

	private List<Items> itemsList = new ArrayList<Items>();

	private List<GeneralCategoriesWOS> generalCategoriesList = new ArrayList<GeneralCategoriesWOS>();

	private List<Integer> breadCrumbIdList = new ArrayList<Integer>();

	private List<GeneralCategories> breadCrumbList = new ArrayList<GeneralCategories>();

	private List<Criterion> criterionList = new ArrayList<Criterion>();

	private List<ItemCategories> itemCategoriesList = new ArrayList<ItemCategories>();

	private List<Languages> languagesList = new ArrayList<Languages>();
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}
		try{
			getAuctionsData();
		}catch (Exception e) {
			return INPUT;
		}

		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}
	public void getAuctionsData(){
		try {
			if(this.pageSize <= 0)
				this.pageSize = 10;

			languagesList =  (List<Languages>) ActionContext.getContext().getApplication().get(AdminConstants.LANGUAGES);
			generalOptions = (GeneralOptions) ActionContext.getContext().getApplication().get(AdminConstants.GENERAL_OPTIONS);
			listingOptions = (ListingOptions) ActionContext.getContext().getApplication().get(AdminConstants.LISTING_OPTIONS);
			getCategories();
			if(criterionList.size() > 0){
				criterionList.clear();
			}
			if (request.getParameter("init") == null || request.getParameter("init").equals(AdminConstants.NONE)) {
				if (request.getSession().getAttribute("searchItemsList") != null) {
					this.itemsList = (List<Items>) request.getSession().getAttribute("searchItemsList");
					this.terms = request.getSession().getAttribute("terms").toString();
					this.searchBy = request.getSession().getAttribute("searchBy").toString();
					this.language = request.getSession().getAttribute("language").toString();

					getItems(itemsList);
				}else{
					getItemList(itemCategoriesList);
				}
			} else {
				request.getSession().setAttribute("searchItemsList", null);
				getItemList(itemCategoriesList);
			}

			if((request.getParameter("title") != null) && (!request.getParameter("title").equals(AdminConstants.NONE))){
				this.itemsList = Sort.byItemTitle(itemsList);
				sort = "title";
			}else if ((request.getParameter("image") != null) && (!request.getParameter("image").equals(AdminConstants.NONE))){
				this.itemsList = Sort.byItemImage(itemsList);
				sort = "image";
			}else if((request.getParameter("buyPrice") != null) && (!request.getParameter("buyPrice").equals(AdminConstants.NONE))){
				this.itemsList = Sort.byItemBuyPrice(itemsList);
				sort = "buyPrice";
			}else if((request.getParameter("bidsSize") != null) && (!request.getParameter("bidsSize").equals(AdminConstants.NONE))){
				this.itemsList = Sort.byItemBidSize(itemsList);
				sort = "bidsSize";
			}else if((request.getParameter("endTime") != null) && (!request.getParameter("endTime").equals(AdminConstants.NONE))){
				this.itemsList = Sort.byItemTime(itemsList);
				sort = "endTime";
			}

		} catch (Exception e) {
			addActionError("Auctions data can not be retrieved.");
		}
	}
	public void getCategories(){
		try {
			if(criterionList.size() > 0){
				criterionList.clear();
			}
			criterionList.add(Restrictions.eq("level", 1));
			criterionList.add(Restrictions.eq("active", true));
			generalCategoriesList = (List<GeneralCategoriesWOS>) CommonFunctionDelegator.getObjectsByCriterion(criterionList, null, null, GeneralCategoriesWOS.class);
			generalCategoriesList = CategoryManagerServiceDelegator.getAllCategories(generalCategoriesList);
			if((request.getParameter(AdminConstants.CATEGORYID)!= null) && (!request.getParameter(AdminConstants.CATEGORYID).equals(AdminConstants.NONE))){
				request.getSession().setAttribute("searchItemsList", null);
				int id = Integer.parseInt(request.getParameter(AdminConstants.CATEGORYID));
				GeneralCategories generalCategories = CategoryManagerServiceDelegator.get(id);
				GeneralCategoriesWOS generalCategoriesWOS = CategoryManagerServiceDelegator.getWOS(id);
				GeneralCategories mainGeneralCategories = CategoryManagerServiceDelegator.get(id);
				breadCrumbIdList = CategoryManagerServiceDelegator.getBreadCrumbList(generalCategories, mainGeneralCategories);
				for (Iterator<Integer> iterator = breadCrumbIdList.iterator(); iterator.hasNext();) {
					int categoryId = Integer.parseInt(iterator.next().toString());
					GeneralCategories categories = CategoryManagerServiceDelegator.get(categoryId);
					breadCrumbList.add(categories);
				}
				if(criterionList.size() > 0){
					criterionList.clear();
				}
				criterionList.add(Restrictions.eq("generalCategories.categoryId" ,id));
				criterionList.add(Restrictions.neProperty("generalCategories.categoryId" ,"categoryId" ));
				generalCategoriesList = (List<GeneralCategoriesWOS>) CommonFunctionDelegator.getObjectsByCriterion(criterionList, null, null, GeneralCategoriesWOS.class);
				generalCategoriesList = CategoryManagerServiceDelegator.getAllCategories(generalCategoriesList);
				if(criterionList.size() > 0){
					criterionList.clear();
				}
				criterionList.add(Restrictions.eq("categoryId", generalCategoriesWOS));
				itemCategoriesList = (List<ItemCategories>) CommonFunctionDelegator.getObjectsByCriterion(criterionList, null, null, ItemCategories.class);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	public void getItemList(List<ItemCategories> itemCategoriesList){
		try{
			if(itemCategoriesList.size() > 0){
				for (Iterator iterator = itemCategoriesList.iterator(); iterator
						.hasNext();) {
					ItemCategories itemCategories = (ItemCategories) iterator.next();
					Items items = itemCategories.getItemId();
					if(items.getItemtype().getId().intValue() == 1 || items.getItemtype().getId().intValue() == 2 || items.getItemtype().getId().intValue() == 3){
						this.itemsList.add(items);
					}
				}
			}else {
				if(criterionList.size() > 0){
					criterionList.clear();
				}
				criterionList.add(Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class))));
				this.itemsList = (List<Items>) CommonFunctionDelegator.getObjectsByCriterion(criterionList, null, null, Items.class);
			}
			getItems(itemsList);
		}catch (Exception e) {
			addActionError("Error in getting items.");
		}
	}

	public void getItems(List<Items> itemsList) {
		try {
			this.itemsList = new ArrayList<Items>();
			List<Items> itemsTempList = new ArrayList<Items>();
			itemsTempList = itemsList;
			List<Transactions> list = null;
 			for (Iterator iterator = itemsTempList.iterator(); iterator.hasNext();) {
				Items items = (Items) iterator.next();
				Transactions transactions = new Transactions();
				if (criterionList.size() > 0) {
					criterionList.clear();
				}
				criterionList.add(Restrictions.eq(AdminConstants.ID, items));
				criterionList.add(Restrictions.eq(AdminConstants.USER, items
						.getUserId()));
				list = new ArrayList<Transactions>();
				list = (List<Transactions>) CommonFunctionDelegator
						.getObjectsByCriterion(criterionList, null, null,
								Transactions.class);
				if(list.size() > 0){
					items.setTransactions(list.get(AdminConstants.ZERO_NUMBER));
				}
				String[] giftIcon;
				giftIcon = items.getGiftIcon().split(AdminConstants.SEMICOLON);
				if (giftIcon.length > 0) {
					items.setGiftIcon(giftIcon[0]);
				}
				if (items.getEndTime().before(DateUtil.getTodaysDate())) {
					items.setClosed(true);
				} else {
					items.setClosed(false);
				}
				if(items.getStartTime().before(DateUtil.addDate(DateUtil.getTodaysDate(), Calendar.DATE, listingOptions.getNumberOfDaysForNewListings()))){
					items.setNewIcon(true);
				}else{
					items.setNewIcon(false);
				}
				this.itemsList.add(items);
			}
		} catch (Exception e) {
			addActionError("Can not get Items.");
		}
	}

	public String searchAuctionsManager() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}

//		List<Criterion> criterionList = new ArrayList<Criterion>();
		try {
			getCategories();
			languagesList =  (List<Languages>) ActionContext.getContext().getApplication().get(AdminConstants.LANGUAGES);
			generalOptions = (GeneralOptions) ActionContext.getContext().getApplication().get(AdminConstants.GENERAL_OPTIONS);
			listingOptions = (ListingOptions) ActionContext.getContext().getApplication().get(AdminConstants.LISTING_OPTIONS);
			String searchString = this.terms + "%";
			if(criterionList.size() > 0){
				criterionList.clear();
			}
			if(this.language.equalsIgnoreCase("All")){
			}else{
				criterionList.add(Restrictions.and(Restrictions.ilike("itemLanguage.languageCode", language), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
			if(this.searchBy.equals("Keywords")) {
				criterionList.add(Restrictions.and(Restrictions.ilike("title", searchString), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
			else if(this.searchBy.equals("Account")) {
				criterionList.add(Restrictions.and(Restrictions.eq("userId", UserServiceDelegator.getUserByUserId(this.terms)), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
			else if(this.searchBy.equals("ID")) {
				criterionList.add(Restrictions.and(Restrictions.eq("itemId", Integer.parseInt(this.terms)), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
			else if(this.searchBy.equals("Location")) {
				SearchCriteria searchCriteria = new SearchCriteria();
				searchCriteria.setAttribute("categoryName", this.terms);
				List<LocationCategoriesWOS> tmpList = (List<LocationCategoriesWOS>) CommonFunctionDelegator.getObjectBySearchCriteria(searchCriteria, LocationCategoriesWOS.class);
				criterionList.add(Restrictions.and(Restrictions.eq("locationCategoriesByState", (tmpList != null && tmpList.size() > 0) ? tmpList.get(0) : null), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
			else if(this.searchBy.equals("Country")) {
				SearchCriteria searchCriteria = new SearchCriteria();
				searchCriteria.setAttribute("categoryName", this.terms);
				List<LocationCategoriesWOS> tmpList = (List<LocationCategoriesWOS>) CommonFunctionDelegator.getObjectBySearchCriteria(searchCriteria, LocationCategoriesWOS.class);
				criterionList.add(Restrictions.and(Restrictions.eq("locationCategoriesByCountry", (tmpList != null && tmpList.size() > 0) ? tmpList.get(0) : null), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
			else if(this.searchBy.equals("Region")) {
				SearchCriteria searchCriteria = new SearchCriteria();
				searchCriteria.setAttribute("categoryName", this.terms);
				List<LocationCategoriesWOS> tmpList = (List<LocationCategoriesWOS>) CommonFunctionDelegator.getObjectBySearchCriteria(searchCriteria, LocationCategoriesWOS.class);
				criterionList.add(Restrictions.and(Restrictions.eq("locationCategoriesByRegion", (tmpList != null && tmpList.size() > 0) ? tmpList.get(0) : null), Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class)))));
			}
		} catch (Exception e) {
			e.printStackTrace();
			addActionMessage("Error while processing search criteria...");
		}

		criterionList.add(Restrictions.or(Restrictions.or(Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 1, Itemtype.class)), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 2, Itemtype.class))), Restrictions.eq("itemtype", CommonFunctionDelegator.getObjectById("id", 3, Itemtype.class))));
		this.itemsList = (List<Items>) CommonFunctionDelegator.getObjectsByCriterion(criterionList, null, null, Items.class);

		if(sort != null && !sort.equals(AdminConstants.NONE)){
			if(sort.equals("title")){
				this.itemsList = Sort.byItemTitle(itemsList);
				sort = "title";
			}else if (sort.equals("image")){
				this.itemsList = Sort.byItemImage(itemsList);
				sort = "image";
			}else if(sort.equals("buyPrice")){
				this.itemsList = Sort.byItemBuyPrice(itemsList);
				sort = "buyPrice";
			}else if(sort.equals("bidsSize")){
				this.itemsList = Sort.byItemBidSize(itemsList);
				sort = "bidsSize";
			}else if(sort.equals("endTime")){
				this.itemsList = Sort.byItemTime(itemsList);
				sort = "endTime";
			}
		}
		getItems(itemsList);
		request.getSession().setAttribute("searchItemsList", itemsList);
		request.getSession().setAttribute("terms", terms);
		request.getSession().setAttribute("searchBy", searchBy);
		request.getSession().setAttribute("language", language);
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}

	public String closeAuction(){
		try {
			if((request.getParameter("itemId") != null) && (request.getParameter("closeAuction") != null)){
				Items item = ItemsServiceDelegator.getItemsById(Integer.parseInt(request.getParameter("itemId")));
				BidStatus bidStatus = new BidStatus(5);
				item.setStatus(bidStatus);
				CommonFunctionDelegator.generalUpdatebyobj(item);
				logger.info("Item closed successfully.");
				addActionMessage("Item closed successfully.");
			}
		} catch (Exception e) {
			return INPUT;
		}
		return SUCCESS;
	}

	public String performAuctionsOperation(){
		try {
			if(this.pageSize <= 0)
				this.pageSize = 10;
			boolean done = false;
			if (request.getParameter("close_check_list") != null) {
				String[] checkedId = request
						.getParameterValues("close_check_list");
				for (String chkid : checkedId) {
					if ((chkid != null) && (!chkid.equals(AdminConstants.NONE))) {
						Items item = ItemsServiceDelegator.getItemsById(Integer
								.parseInt(chkid));
						BidStatus bidStatus = new BidStatus(5);
						item.setStatus(bidStatus);
						if (item != null) {
							CommonFunctionDelegator.generalUpdatebyobj(item);
							done = true;
						}
					}
				}
				logger.info("Items closed successfully.");
			}
			if(done){
				addActionMessage("Items closed successfully.");
			}
			done = false;
			if (request.getParameter("delete_check_list") != null) {
				String[] checkedId = request
						.getParameterValues("delete_check_list");
				for (String chkid : checkedId) {
					if ((chkid != null) && (!chkid.equals(AdminConstants.NONE))) {
						Items item = ItemsServiceDelegator.getItemsById(Integer
								.parseInt(chkid));
						if (item != null) {
							CommonFunctionDelegator.GeneralDelete(item);
							done = true;
						}
					}
				}
				logger.info("Items deleted successfully.");
			}
			if(done){
				addActionMessage("Items deleted successfully.");
			}
			done = false;
			if (request.getParameter("cancel_check_list") != null) {
				String[] checkedId = request
						.getParameterValues("cancel_check_list");
				for (String chkid : checkedId) {
					if ((chkid != null) && (!chkid.equals(AdminConstants.NONE))) {
						Items item = ItemsServiceDelegator.getItemsById(Integer
								.parseInt(chkid));
						BidStatus bidStatus = new BidStatus(
								AdminConstants.ONE_NUMBER);
						item.setStatus(bidStatus);
						if (item != null) {
							CommonFunctionDelegator.generalUpdatebyobj(item);
							done = true;
						}
					}
				}
				logger.info("Items cancelled successfully.");
			}
			if(done){
				addActionMessage("Items cancelled successfully.");
			}
			done = false;
			if (request.getParameter("relist_check_list") != null) {
				String[] checkedId = request
						.getParameterValues("relist_check_list");
				for (String chkid : checkedId) {
					if ((chkid != null) && (!chkid.equals(AdminConstants.NONE))) {
						Items item = ItemsServiceDelegator.getItemsById(Integer
								.parseInt(chkid));
						BidStatus bidStatus = new BidStatus(4);
						item.setStatus(bidStatus);
						item.setStartTime(DateUtil.getTodaysDate());
						item.setEndTime(DateUtil.addDate(item.getStartTime(), Calendar.DATE, Integer.parseInt(item.getDuration())));
						if (item != null) {
							CommonFunctionDelegator.generalUpdatebyobj(item);
							done = true;
						}
					}
				}
				logger.info("Items relisted successfully.");
			}
			if(done){
				addActionMessage("Items relisted successfully.");
			}
			done = false;
//			getAuctionsData();
		}catch (Exception e) {
			return INPUT;
		}
		return SUCCESS;
	}

	public String deleteAuction(){
		try {
			if((request.getParameter("itemId") != null) && (request.getParameter("deleteAuction") != null)){
				Items item = ItemsServiceDelegator.getItemsById(Integer.parseInt(request.getParameter("itemId")));
				CommonFunctionDelegator.GeneralDelete(item);
				addActionMessage("Item deleted successfully.");
				logger.info("Item deleted successfully.");
			}
		} catch (Exception e) {
			return INPUT;
		}
		return SUCCESS;
	}

	public String cancelAuction(){
		try {
			if((request.getParameter("itemId") != null) && (request.getParameter("cancelAuction") != null)){
				Items item = ItemsServiceDelegator.getItemsById(Integer.parseInt(request.getParameter("itemId")));
				BidStatus bidStatus = new BidStatus(AdminConstants.ONE_NUMBER);
				item.setStatus(bidStatus);
				CommonFunctionDelegator.generalUpdatebyobj(item);
				addActionMessage("Item canceled successfully.");
				logger.info("Item canceled successfully.");
			}
		} catch (Exception e) {
			return INPUT;
		}
		return SUCCESS;
	}

	public String relistAuction(){
		try {
			if((request.getParameter("itemId") != null) && (request.getParameter("relistAuction") != null)){
				Items item = ItemsServiceDelegator.getItemsById(Integer.parseInt(request.getParameter("itemId")));
				BidStatus bidStatus = new BidStatus(4);
				item.setStatus(bidStatus);
				item.setStartTime(DateUtil.getTodaysDate());
				item.setEndTime(DateUtil.addDate(item.getStartTime(), Calendar.DATE, Integer.parseInt(item.getDuration())));
				CommonFunctionDelegator.generalUpdatebyobj(item);
				addActionMessage("Item relisted successfully.");
				logger.info("Item relisted successfully.");
			}
		} catch (Exception e) {
			return INPUT;
		}
		return SUCCESS;
	}
	public List<Items> getItemsList() {
		return itemsList;
	}

	public String getSearchBy() {
		return searchBy;
	}

	public void setSearchBy(String searchBy) {
		this.searchBy = searchBy;
	}

	public String getTerms() {
		return terms;
	}

	public void setTerms(String terms) {
		this.terms = terms;
	}

	public void setServletRequest(HttpServletRequest arg0) {
		request = arg0;
	}

	public List<GeneralCategoriesWOS> getGeneralCategoriesList() {
		return generalCategoriesList;
	}

	public void setGeneralCategoriesList(
			List<GeneralCategoriesWOS> generalCategoriesList) {
		this.generalCategoriesList = generalCategoriesList;
	}

	public List<GeneralCategories> getBreadCrumbList() {
		return breadCrumbList;
	}

	public void setBreadCrumbList(List<GeneralCategories> breadCrumbList) {
		this.breadCrumbList = breadCrumbList;
	}

	public TypedValue[] getTypedValues(Criteria criteria,
			CriteriaQuery criteriaQuery) throws HibernateException {
		// TODO Auto-generated method stub
		return null;
	}

	public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
			throws HibernateException {
		criteria.addOrder(Order.asc("title"));
		return null;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public GeneralOptions getGeneralOptions() {
		return generalOptions;
	}

	public void setGeneralOptions(GeneralOptions generalOptions) {
		this.generalOptions = generalOptions;
	}

	public List<Languages> getLanguagesList() {
		return languagesList;
	}

	public void setLanguagesList(List<Languages> languagesList) {
		this.languagesList = languagesList;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public ListingOptions getListingOptions() {
		return listingOptions;
	}

	public void setListingOptions(ListingOptions listingOptions) {
		this.listingOptions = listingOptions;
	}

}